package com.googlecode.hypersphere.ws2ejb3.xml.mock;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

import org.dom4j.Document;

import com.googlecode.hypersphere.ws2ejb3.xml.Query;

public class MockQuery implements Query {

	private String query;
	private int index = 0;
	private List<String> assertions = new ArrayList<String>();

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public String valueOf(Document doc) {
		String result = doc.valueOf(getQuery());
		if (index < assertions.size()) {
			TestCase.assertEquals(assertions.get(index), result);
			index++;
		}
		return result;
	}

	public void addAssertions(String result) {
		assertions.add(result);
	}

}
